package com.cenntro.oss.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cenntro.common.base.BaseServiceImpl;
import com.cenntro.oss.mapper.DevFollowMapper;
import com.cenntro.oss.model.dbo.DevFollowDO;
import com.cenntro.oss.service.DevFollowService;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author
 * @since 2019-02-22
 */
@Service
public class DevFollowServiceImpl extends BaseServiceImpl<DevFollowMapper> implements DevFollowService {

    @Resource
    private DevFollowMapper devFollowMapper;

    @Override
    public Integer delete(Integer devId) {
        List<DevFollowDO> followDO = devFollowMapper.delete(devId);
        if (followDO.size() != 0) {
            for (int i = 0; i < followDO.size(); i++) {
                if (followDO.get(i).getId() != null) {
                    int id = devFollowMapper.deleteById(followDO.get(i).getId());
                    if (id > 0) {
                        return 1;
                    } else {
                        return -1;
                    }
                } 
            }
        }
        return 0;
    }
}
